import { IPSApplication } from '../../app/ipsapplication';
import { IPSAppDEUILogic } from '../../app/dataentity/ipsapp-deuilogic';
import { IPSAppDataEntity } from '../../app/dataentity/ipsapp-data-entity';
import { IPSAppUILogic } from '../../app/logic/ipsapp-uilogic';
import { IPSAppViewEngine } from '../../app/view/ipsapp-view-engine';
import { IPSAppViewLogic } from '../../app/view/ipsapp-view-logic';
import { IPSAppViewUIAction } from '../../app/view/ipsapp-view-uiaction';
import { IPSSysPanelLogic } from './ipssys-panel-logic';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSSysPanelLogicImpl extends PSModelObjectImpl implements IPSSysPanelLogic {
  get attrName(): string {
    return this.M.attrName;
  }

  get codeName(): string {
    return this.M.codeName;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get eventArg(): string {
    return this.M.eventArg;
  }

  get eventArg2(): string {
    return this.M.eventArg2;
  }

  get eventNames(): string {
    return this.M.eventNames;
  }

  get itemName(): string {
    return this.M.itemName;
  }

  get logicName(): string {
    return this.M.logicName;
  }

  get logicParam(): string {
    return this.M.logicParam;
  }

  get logicParam2(): string {
    return this.M.logicParam2;
  }

  get logicTrigger(): 'TIMER' | 'PANELEVENT' | 'CTRLEVENT' | 'ITEMVISIBLE' | 'ITEMENABLE' | 'ITEMBLANK' | 'ITEMDYNACLASS' | 'RENDER' | 'ATTRIBUTE' | 'CUSTOM' | 'VUE_DIRECTIVE' {
    return this.M.logicTrigger;
  }

  get logicType(): 'APPDEUILOGIC' | 'APPDEUIACTION' | 'APPUILOGIC' | 'APPVIEWLOGIC' | 'APPVIEWENGINE' | 'PFPLUGIN' | 'SCRIPT' | 'DEUILOGIC' | 'DEUIACTION' | 'SYSVIEWLOGIC' {
    return this.M.logicType;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  get owner(): IModel {
    return this.M.owner;
  }

  protected psappdeuilogic: IPSAppDEUILogic | null = null;

  getPSAppDEUILogic(): IPSAppDEUILogic | null {
    if (this.psappdeuilogic != null) return this.psappdeuilogic;
    const value = this.M.getPSAppDEUILogic;
    if (value == null) {
      return null;
    }
    const ipsappdataentity = this.getPSAppDataEntity();
    if (ipsappdataentity != null) {
      this.psappdeuilogic = ipsappdataentity.findPSAppDEUILogic(value);
    }
    return this.psappdeuilogic;
  }

  get psAppDEUILogic(): IPSAppDEUILogic | null {
    return this.getPSAppDEUILogic();
  }

  getPSAppDEUILogicMust(): IPSAppDEUILogic {
    const value = this.getPSAppDEUILogic();
    if (value == null) {
      throw new Error('未指定应用实体界面逻辑');
    }
    return value;
  }

  protected psappdataentity: IPSAppDataEntity | null = null;

  getPSAppDataEntity(): IPSAppDataEntity | null {
    if (this.psappdataentity != null) return this.psappdataentity;
    const value = this.M.getPSAppDataEntity;
    if (value == null) {
      return null;
    }
    this.psappdataentity = this.getPSModel4('app.dataentity.IPSAppDataEntity', value, 'getPSAppDataEntity') as IPSAppDataEntity;
    return this.psappdataentity;
  }

  get psAppDataEntity(): IPSAppDataEntity | null {
    return this.getPSAppDataEntity();
  }

  getPSAppDataEntityMust(): IPSAppDataEntity {
    const value = this.getPSAppDataEntity();
    if (value == null) {
      throw new Error('未指定应用实体对象');
    }
    return value;
  }

  protected psappuilogic: IPSAppUILogic | null = null;

  getPSAppUILogic(): IPSAppUILogic | null {
    if (this.psappuilogic != null) return this.psappuilogic;
    const value = this.M.getPSAppUILogic;
    if (value == null) {
      return null;
    }
    const ipsapplication = this.getParentPSModelObject('app.IPSApplication') as IPSApplication;
    if (ipsapplication != null) {
      this.psappuilogic = ipsapplication.findPSAppUILogic(value);
    }
    return this.psappuilogic;
  }

  get psAppUILogic(): IPSAppUILogic | null {
    return this.getPSAppUILogic();
  }

  getPSAppUILogicMust(): IPSAppUILogic {
    const value = this.getPSAppUILogic();
    if (value == null) {
      throw new Error('未指定应用预置界面逻辑');
    }
    return value;
  }

  protected psappviewengine: IPSAppViewEngine | null = null;

  getPSAppViewEngine(): IPSAppViewEngine | null {
    if (this.psappviewengine != null) return this.psappviewengine;
    const value = this.M.getPSAppViewEngine;
    if (value == null) {
      return null;
    }
    this.psappviewengine = this.getPSModel4('app.view.IPSAppViewEngine', value, 'getPSAppViewEngine') as IPSAppViewEngine;
    return this.psappviewengine;
  }

  get psAppViewEngine(): IPSAppViewEngine | null {
    return this.getPSAppViewEngine();
  }

  getPSAppViewEngineMust(): IPSAppViewEngine {
    const value = this.getPSAppViewEngine();
    if (value == null) {
      throw new Error('未指定视图界面引擎');
    }
    return value;
  }

  protected psappviewlogic: IPSAppViewLogic | null = null;

  getPSAppViewLogic(): IPSAppViewLogic | null {
    if (this.psappviewlogic != null) return this.psappviewlogic;
    const value = this.M.getPSAppViewLogic;
    if (value == null) {
      return null;
    }
    this.psappviewlogic = this.getPSModel4('app.view.IPSAppViewLogic', value, 'getPSAppViewLogic') as IPSAppViewLogic;
    return this.psappviewlogic;
  }

  get psAppViewLogic(): IPSAppViewLogic | null {
    return this.getPSAppViewLogic();
  }

  getPSAppViewLogicMust(): IPSAppViewLogic {
    const value = this.getPSAppViewLogic();
    if (value == null) {
      throw new Error('未指定调用视图逻辑');
    }
    return value;
  }

  protected psappviewuiaction: IPSAppViewUIAction | null = null;

  getPSAppViewUIAction(): IPSAppViewUIAction | null {
    if (this.psappviewuiaction != null) return this.psappviewuiaction;
    const value = this.M.getPSAppViewUIAction;
    if (value == null) {
      return null;
    }
    this.psappviewuiaction = this.getPSModel4('app.view.IPSAppViewUIAction', value, 'getPSAppViewUIAction') as IPSAppViewUIAction;
    return this.psappviewuiaction;
  }

  get psAppViewUIAction(): IPSAppViewUIAction | null {
    return this.getPSAppViewUIAction();
  }

  getPSAppViewUIActionMust(): IPSAppViewUIAction {
    const value = this.getPSAppViewUIAction();
    if (value == null) {
      throw new Error('未指定应用视图界面行为');
    }
    return value;
  }

  get psViewCtrlName(): string {
    return this.M.getPSViewCtrlName;
  }

  getPSViewCtrlName(): string {
    return this.M.getPSViewCtrlName;
  }

  get scriptCode(): string {
    return this.M.scriptCode;
  }

  get timer(): number {
    return this.M.timer != null ? this.M.timer : 0;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get builtinLogic(): boolean {
    return this.M.builtinLogic != null ? this.M.builtinLogic : true;
  }

  get cls(): string {
    return 'PSSysPanelLogicImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'app.view.IPSAppViewLogic' || cls == 'control.panel.IPSPanelLogic' || cls == 'control.panel.IPSPanelObject' || cls == 'control.panel.IPSSysPanelLogic') return true;
    return super.instanceof(cls);
  }
}
